home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / vla / waves.lzh / changeit.asm next >
Assembly Source File  |  1993-06-14  |  5KB  |  236 lines

  1.     Dosseg
  2.     .Model Small
  3.     .Stack 200h
  4.     .Code
  5.     .386
  6.     Assume CS:@CODE, DS:@CODE
  7.     Ideal
  8. ────────────────────────────────────────────────────────────────────────────
  9. Include "Vga16.inc"
  10.  
  11. PictureSeg  dw  ?
  12. PictureName db  "VlaVla.TGA",0
  13. Save1       db  "plane1.dat",0
  14. Save2       db  "plane2.dat",0
  15.  
  16. Palette     db  38*64/100, 30*64/100, 28*64/100
  17.             db  53*64/100, 42*64/100, 41*64/100
  18.             db  27*64/100, 20*64/100, 20*64/100
  19.             db  75*64/100, 59*64/100, 56*64/100
  20. ────────────────────────────────────────────────────────────────────────────
  21. PROC LoadThePicture
  22.     pusha
  23.     push    ds
  24.     mov     ax,cs
  25.     mov     ds,ax
  26.  
  27.     mov     ax,3d00h
  28.     mov     dx,offset PictureName
  29.     int     21h
  30.     jc      @@NoFile
  31.     mov     bx,ax
  32.  
  33.     xor     cx,cx
  34.     mov     dx,768+18
  35.     mov     ax,4200h        ;move file ptr past header of tga
  36.     int     21h
  37.  
  38.     mov     bp,[PictureSeg]
  39. @@LoadLoop:
  40.     mov     ds,bp
  41.     xor     dx,dx
  42.     mov     cx,0fff0h
  43.     mov     ah,3fh
  44.     int     21h             ;read 0FFF0h bytes
  45.     cmp     cx,ax
  46.     jne     @@Alldone       ;we are done if ax != cx
  47.  
  48.     add     bp,0fffh
  49.     jmp     @@LoadLoop
  50. @@AllDone:
  51.     mov     ah,3eh
  52.     int     21h
  53.  
  54. @@NoFile:
  55.     pop     ds
  56.     popa
  57.     ret
  58. ENDP
  59.  
  60. PROC SeperateThePicture
  61.     pusha
  62.     push    ds es
  63.     mov     es,[cs:VGAseg]
  64.  
  65.     mov     ah,0001b
  66.     @Set_Write_Plane
  67.  
  68.     mov     bp,640*480/8
  69.     xor     si,si
  70.     mov     ds,[cs:PictureSeg]   
  71.     xor     di,di
  72.     cld
  73. @@BigLoop:
  74.     xor     bl,bl
  75.     lodsw
  76.     and     ax,0000000100000001b
  77.     or      bl,al
  78.     shl     bl,1
  79.     or      bl,ah
  80.     shl     bl,1
  81.     lodsw
  82.     and     ax,0000000100000001b
  83.     or      bl,al
  84.     shl     bl,1
  85.     or      bl,ah
  86.     shl     bl,1
  87.     lodsw
  88.     and     ax,0000000100000001b
  89.     or      bl,al
  90.     shl     bl,1
  91.     or      bl,ah
  92.     shl     bl,1
  93.     lodsw
  94.     and     ax,0000000100000001b
  95.     or      bl,al
  96.     shl     bl,1
  97.     or      bl,ah
  98.     ;shl     bl,1
  99.     mov     al,bl
  100.     stosb
  101.  
  102.     mov     ax,ds
  103.     mov     bx,si
  104.     shr     bx,4
  105.     add     ax,bx
  106.     mov     ds,ax
  107.     and     si,0fh  ;fix up ds:si
  108.                                  
  109.     dec     bp
  110.     jne     @@BigLoop
  111.  
  112.     mov     ah,0010b
  113.     @Set_Write_Plane
  114.  
  115.     mov     bp,640*480/8
  116.     xor     si,si
  117.     mov     ds,[cs:PictureSeg]
  118.     xor     di,di
  119.     cld
  120. @@BigLoop2:
  121.     xor     bl,bl
  122.     lodsw
  123.     and     ax,0000001000000010b
  124.     or      bl,al
  125.     shl     bl,1
  126.     or      bl,ah
  127.     shl     bl,1
  128.     lodsw
  129.     and     ax,0000001000000010b
  130.     or      bl,al
  131.     shl     bl,1
  132.     or      bl,ah
  133.     shl     bl,1
  134.     lodsw
  135.     and     ax,0000001000000010b
  136.     or      bl,al
  137.     shl     bl,1
  138.     or      bl,ah
  139.     shl     bl,1
  140.     lodsw
  141.     and     ax,0000001000000010b
  142.     or      bl,al
  143.     rol     bl,1
  144.     or      bl,ah
  145.     ror     bl,1
  146.     mov     al,bl
  147.     stosb
  148.  
  149.     mov     ax,ds
  150.     mov     bx,si
  151.     shr     bx,4
  152.     add     ax,bx
  153.     mov     ds,ax
  154.     and     si,0fh  ;fix up ds:si
  155.                                  
  156.     dec     bp
  157.     jne     @@BigLoop2
  158.  
  159.     pop     es ds
  160.     popa
  161.     ret
  162. ENDP
  163.  
  164. PROC SaveThePicture
  165.     mov     ax,cs
  166.     mov     ds,ax
  167.  
  168.     mov     ah,0
  169.     @Set_Read_Plane
  170.  
  171.     mov     ax,3c00h        ;create file
  172.     mov     dx,offset Save1
  173.     int     21h
  174.     mov     bx,ax
  175.  
  176.     mov     ds,[VgaSeg]
  177.     xor     dx,dx
  178.     mov     cx,640/8*480
  179.     mov     ah,40h
  180.     int     21h
  181.  
  182.     mov     ah,3eh
  183.     int     21h
  184.  
  185.     mov     ax,cs
  186.     mov     ds,ax
  187.     
  188.     mov     ah,1
  189.     @Set_Read_Plane
  190.  
  191.     mov     ax,3c00h        ;create file
  192.     mov     dx,offset Save2
  193.     int     21h
  194.     mov     bx,ax
  195.  
  196.     mov     ds,[VgaSeg]
  197.     xor     dx,dx
  198.     mov     cx,640/8*480
  199.     mov     ah,40h
  200.     int     21h
  201.  
  202.     mov     ah,3eh
  203.     int     21h
  204.  
  205.     ret
  206. ENDP
  207. ────────────────────────────────────────────────────────────────────────────
  208. Start:
  209.     mov     ax,cs
  210.     mov     ds,ax
  211.     mov     ax,ss
  212.     add     ax,20h
  213.     mov     [PictureSeg],ax
  214.  
  215.     mov     ax,12h
  216.     int     10h
  217.  
  218.     mov     si,offset Palette
  219.     mov     cx,4
  220.     mov     al,0
  221.     @WritePalette
  222.  
  223.     call    LoadThePicture
  224.  
  225.     call    SeperateThePicture
  226.  
  227.     call    SaveThePicture
  228.  
  229.     mov     ah,0
  230.     int     16h
  231.     mov     ax,3
  232.     int     10h
  233.     mov     ah,4ch
  234.     int     21h
  235. ENd Start
  236.